// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::invalid_html_tags)]

/// Implements a client for the OS Config API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_osconfig_v1::client::OsConfigService;
/// let client = OsConfigService::builder().build().await?;
/// // use `client` to make requests to the OS Config API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// OS Config API
///
/// The OS Config service is a server-side component that you can use to
/// manage package installations and patch jobs for virtual machine instances.
///
/// # Configuration
///
/// To configure `OsConfigService` use the `with_*` methods in the type returned
/// by [builder()][OsConfigService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://osconfig.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::os_config_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::os_config_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `OsConfigService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `OsConfigService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct OsConfigService {
    inner: std::sync::Arc<dyn super::stub::dynamic::OsConfigService>,
}

impl OsConfigService {
    /// Returns a builder for [OsConfigService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_osconfig_v1::client::OsConfigService;
    /// let client = OsConfigService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::os_config_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::os_config_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::OsConfigService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::OsConfigService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::OsConfigService> {
        super::transport::OsConfigService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::OsConfigService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::OsConfigService::new)
    }

    /// Patch VM instances by creating and running a patch job.
    pub fn execute_patch_job(&self) -> super::builder::os_config_service::ExecutePatchJob {
        super::builder::os_config_service::ExecutePatchJob::new(self.inner.clone())
    }

    /// Get the patch job. This can be used to track the progress of an
    /// ongoing patch job or review the details of completed jobs.
    pub fn get_patch_job(&self) -> super::builder::os_config_service::GetPatchJob {
        super::builder::os_config_service::GetPatchJob::new(self.inner.clone())
    }

    /// Cancel a patch job. The patch job must be active. Canceled patch jobs
    /// cannot be restarted.
    pub fn cancel_patch_job(&self) -> super::builder::os_config_service::CancelPatchJob {
        super::builder::os_config_service::CancelPatchJob::new(self.inner.clone())
    }

    /// Get a list of patch jobs.
    pub fn list_patch_jobs(&self) -> super::builder::os_config_service::ListPatchJobs {
        super::builder::os_config_service::ListPatchJobs::new(self.inner.clone())
    }

    /// Get a list of instance details for a given patch job.
    pub fn list_patch_job_instance_details(
        &self,
    ) -> super::builder::os_config_service::ListPatchJobInstanceDetails {
        super::builder::os_config_service::ListPatchJobInstanceDetails::new(self.inner.clone())
    }

    /// Create an OS Config patch deployment.
    pub fn create_patch_deployment(
        &self,
    ) -> super::builder::os_config_service::CreatePatchDeployment {
        super::builder::os_config_service::CreatePatchDeployment::new(self.inner.clone())
    }

    /// Get an OS Config patch deployment.
    pub fn get_patch_deployment(&self) -> super::builder::os_config_service::GetPatchDeployment {
        super::builder::os_config_service::GetPatchDeployment::new(self.inner.clone())
    }

    /// Get a page of OS Config patch deployments.
    pub fn list_patch_deployments(
        &self,
    ) -> super::builder::os_config_service::ListPatchDeployments {
        super::builder::os_config_service::ListPatchDeployments::new(self.inner.clone())
    }

    /// Delete an OS Config patch deployment.
    pub fn delete_patch_deployment(
        &self,
    ) -> super::builder::os_config_service::DeletePatchDeployment {
        super::builder::os_config_service::DeletePatchDeployment::new(self.inner.clone())
    }

    /// Update an OS Config patch deployment.
    pub fn update_patch_deployment(
        &self,
    ) -> super::builder::os_config_service::UpdatePatchDeployment {
        super::builder::os_config_service::UpdatePatchDeployment::new(self.inner.clone())
    }

    /// Change state of patch deployment to "PAUSED".
    /// Patch deployment in paused state doesn't generate patch jobs.
    pub fn pause_patch_deployment(
        &self,
    ) -> super::builder::os_config_service::PausePatchDeployment {
        super::builder::os_config_service::PausePatchDeployment::new(self.inner.clone())
    }

    /// Change state of patch deployment back to "ACTIVE".
    /// Patch deployment in active state continues to generate patch jobs.
    pub fn resume_patch_deployment(
        &self,
    ) -> super::builder::os_config_service::ResumePatchDeployment {
        super::builder::os_config_service::ResumePatchDeployment::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::os_config_service::GetOperation {
        super::builder::os_config_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::os_config_service::CancelOperation {
        super::builder::os_config_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the OS Config API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
/// let client = OsConfigZonalService::builder().build().await?;
/// // use `client` to make requests to the OS Config API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Zonal OS Config API
///
/// The OS Config service is the server-side component that allows users to
/// manage package installations and patch jobs for Compute Engine VM instances.
///
/// # Configuration
///
/// To configure `OsConfigZonalService` use the `with_*` methods in the type returned
/// by [builder()][OsConfigZonalService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://osconfig.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::os_config_zonal_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::os_config_zonal_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `OsConfigZonalService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `OsConfigZonalService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct OsConfigZonalService {
    inner: std::sync::Arc<dyn super::stub::dynamic::OsConfigZonalService>,
}

impl OsConfigZonalService {
    /// Returns a builder for [OsConfigZonalService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_osconfig_v1::client::OsConfigZonalService;
    /// let client = OsConfigZonalService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::os_config_zonal_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::os_config_zonal_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::OsConfigZonalService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::OsConfigZonalService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::OsConfigZonalService> {
        super::transport::OsConfigZonalService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::OsConfigZonalService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::OsConfigZonalService::new)
    }

    /// Create an OS policy assignment.
    ///
    /// This method also creates the first revision of the OS policy assignment.
    ///
    /// This method returns a long running operation (LRO) that contains the
    /// rollout details. The rollout can be cancelled by cancelling the LRO.
    ///
    /// For more information, see [Method:
    /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_os_policy_assignment(
        &self,
    ) -> super::builder::os_config_zonal_service::CreateOSPolicyAssignment {
        super::builder::os_config_zonal_service::CreateOSPolicyAssignment::new(self.inner.clone())
    }

    /// Update an existing OS policy assignment.
    ///
    /// This method creates a new revision of the OS policy assignment.
    ///
    /// This method returns a long running operation (LRO) that contains the
    /// rollout details. The rollout can be cancelled by cancelling the LRO.
    ///
    /// For more information, see [Method:
    /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_os_policy_assignment(
        &self,
    ) -> super::builder::os_config_zonal_service::UpdateOSPolicyAssignment {
        super::builder::os_config_zonal_service::UpdateOSPolicyAssignment::new(self.inner.clone())
    }

    /// Retrieve an existing OS policy assignment.
    ///
    /// This method always returns the latest revision. In order to retrieve a
    /// previous revision of the assignment, also provide the revision ID in the
    /// `name` parameter.
    pub fn get_os_policy_assignment(
        &self,
    ) -> super::builder::os_config_zonal_service::GetOSPolicyAssignment {
        super::builder::os_config_zonal_service::GetOSPolicyAssignment::new(self.inner.clone())
    }

    /// List the OS policy assignments under the parent resource.
    ///
    /// For each OS policy assignment, the latest revision is returned.
    pub fn list_os_policy_assignments(
        &self,
    ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignments {
        super::builder::os_config_zonal_service::ListOSPolicyAssignments::new(self.inner.clone())
    }

    /// List the OS policy assignment revisions for a given OS policy assignment.
    pub fn list_os_policy_assignment_revisions(
        &self,
    ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignmentRevisions {
        super::builder::os_config_zonal_service::ListOSPolicyAssignmentRevisions::new(
            self.inner.clone(),
        )
    }

    /// Delete the OS policy assignment.
    ///
    /// This method creates a new revision of the OS policy assignment.
    ///
    /// This method returns a long running operation (LRO) that contains the
    /// rollout details. The rollout can be cancelled by cancelling the LRO.
    ///
    /// If the LRO completes and is not cancelled, all revisions associated with
    /// the OS policy assignment are deleted.
    ///
    /// For more information, see [Method:
    /// projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel).
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_os_policy_assignment(
        &self,
    ) -> super::builder::os_config_zonal_service::DeleteOSPolicyAssignment {
        super::builder::os_config_zonal_service::DeleteOSPolicyAssignment::new(self.inner.clone())
    }

    /// Get the OS policy asssignment report for the specified Compute Engine VM
    /// instance.
    pub fn get_os_policy_assignment_report(
        &self,
    ) -> super::builder::os_config_zonal_service::GetOSPolicyAssignmentReport {
        super::builder::os_config_zonal_service::GetOSPolicyAssignmentReport::new(
            self.inner.clone(),
        )
    }

    /// List OS policy asssignment reports for all Compute Engine VM instances in
    /// the specified zone.
    pub fn list_os_policy_assignment_reports(
        &self,
    ) -> super::builder::os_config_zonal_service::ListOSPolicyAssignmentReports {
        super::builder::os_config_zonal_service::ListOSPolicyAssignmentReports::new(
            self.inner.clone(),
        )
    }

    /// Get inventory data for the specified VM instance. If the VM has no
    /// associated inventory, the message `NOT_FOUND` is returned.
    pub fn get_inventory(&self) -> super::builder::os_config_zonal_service::GetInventory {
        super::builder::os_config_zonal_service::GetInventory::new(self.inner.clone())
    }

    /// List inventory data for all VM instances in the specified zone.
    pub fn list_inventories(&self) -> super::builder::os_config_zonal_service::ListInventories {
        super::builder::os_config_zonal_service::ListInventories::new(self.inner.clone())
    }

    /// Gets the vulnerability report for the specified VM instance. Only VMs with
    /// inventory data have vulnerability reports associated with them.
    pub fn get_vulnerability_report(
        &self,
    ) -> super::builder::os_config_zonal_service::GetVulnerabilityReport {
        super::builder::os_config_zonal_service::GetVulnerabilityReport::new(self.inner.clone())
    }

    /// List vulnerability reports for all VM instances in the specified zone.
    pub fn list_vulnerability_reports(
        &self,
    ) -> super::builder::os_config_zonal_service::ListVulnerabilityReports {
        super::builder::os_config_zonal_service::ListVulnerabilityReports::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::os_config_zonal_service::GetOperation {
        super::builder::os_config_zonal_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::os_config_zonal_service::CancelOperation {
        super::builder::os_config_zonal_service::CancelOperation::new(self.inner.clone())
    }
}
